<?php
use yii\helpers\Url;
?>

<style type="text/css">
   .tab{

   }
   .tab tr td{
       height:30px;
       line-height: 30px;
   }
</style>

<div>
    <div>
        <span>总授权数</span><span style="margin-left: 12px;color:red;"><?php echo $list['nums']['total_num'] ?> </span> |
        <span>已使用授权</span><span style="margin-left: 12px;color:red;"><?php echo $list['nums']['used_num'] ?> </span>
    </div>
    <br/>
    <div>
        <a target="_blanks" href="<?php echo Url::toRoute(["mtp/myscrm-organization/add-contract-form", 'orgname' => $orgName]) ?>">新增合同</a>
    </div>
    <br/>
    <table border="1" style="border-collapse:collapse" width="80%" class="tab">
        <tr>
            <th>合同ID</th>
            <th>合同号</th>
            <th>合同甲方</th>
            <th>授权数</th>
            <th>包含套餐</th>
            <th>状态</th>
        </tr>
        <?php
        foreach($list['contracts'] as $contract){?>
        <tr>
        <td><a target="_blank" href="<?php echo Url::toRoute(["mtp/myscrm-organization/edit-contract-form", 'orgname' => $orgName, 'contract_id' => $contract['ContractId']]) ?>">
                <?php echo $contract['ContractId'] ?></a></td>
        <td><?php echo $contract['ContractNum'] ?></td>
        <td><?php echo $contract['PartyA'] ?></td>
        <td><?php echo $contract['nums']['total_num'] ?> | <?php echo $contract['nums']['used_num'] ?> </td>
        <td>
            <?php
            foreach($contract['packages'] as $pkg){
                echo '<div>'.$pkg['friendly_name'].'('.$pkg['unique_name'].')'.'&nbsp;&nbsp;&nbsp;&nbsp;授权:<span style="color:blue;">'
                    .$pkg['total_num'].'|'.$pkg['used_num'].'</span></div>';
            }
            ?>
        </td>
        <td>
            <?php
            if($contract['Status'] == 2){
                echo '作废';
            }else if($contract['Status'] == 1){
                echo '激活';
            }else if($contract['Status'] == 3){
                echo '过期';
            }else{
                echo '其它';
            }
            ?>
        </td>
        </tr>
        <?php
        }
        ?>
    </table>

</div>